public class h_3_demo {
    private boolean isFlag=false;
    Object o=new Object();

    public void ziThread(){
        /* synchronized (o){
            while(isFlag()==true){
                try {
                    o.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            for (int i = 0; i <3 ; i++) {
                System.out.println("子线程");
            }
            isFlag=true;
            o.notify();
        }*/
        for (int i = 0; i <3 ; i++) {
            System.out.println("子线程");
        }
    }

    public void mainThread(){
        for (int i = 0; i <5 ; i++) {
            System.out.println("主线程");
        }

    }
    public boolean isFlag() {
        return isFlag;
    }

    public void setFlag(boolean flag) {
        isFlag = flag;
    }

    public Object getO() {
        return o;
    }

    public void setO(Object o) {
        this.o = o;
    }
}
